import FyComponent from '@/components/common/Interval'
import { Text, View } from '@tarojs/components'
import './index.scss'
import { calcSurplusTime } from "@/utils/utils"

interface IProps {
  seconds: number
  onTimeUp?: any
}

export default class SeckillCountdown extends FyComponent<IProps, {}> {
  state: any

  constructor() {
    super()
    this.state = {
      time: calcSurplusTime()
    }
  }

  //  倒计时回调
  onIntervalCallBack(time) {
    this.setState({
      time
    })
  }

  render() {
    const { time } = this.state
    return (<View className='goods-count-down bnn-number '>
      {/*{!!time.day && <View className='count-down__day'>{time.day}天</View>}*/}
      {!!time.hours && <Text className='count-down__box'>{this.formatNum(time.hours)}</Text>}{!!time.hours && ':'}
      <Text className='count-down__box'>{this.formatNum(time.minutes)}</Text>:
      <Text className='count-down__box'>{this.formatNum(time.seconds)}</Text>:
      <Text className='count-down__box'>{this.formatNum(time.millisecond)}</Text>
    </View>)
  }
}
